<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');

	$lblName 		= $this->cmsLinkSort('Tiêu đề','l.name',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	$lblID 			= $this->cmsLinkSort('ID','l.id',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	$lblStatus 		= $this->cmsLinkSort('Status','l.status',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblOrder 		= $this->cmsLinkSort('Order','l.order',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblCategory	= $this->cmsLinkSort('Thuộc nhóm','category_name',$ssFilter,$this->imgUrl . '/admin',$action_link);

	$lblLanguage	= $this->cmsLinkSort('Ngôn ngữ','l.lang_code',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort'));
	
	//---------------------GROUP SELECTBOX --------------------//
	$linkSlbCategory = $this->baseUrl($this->currentController . '/filter/type/cat_id');
	$selectCategory = $this->cmsSelect('cat_id',$ssFilter['cat_id'],$this->slbCategory,array('style'=>'min-width:200px;','onchange'=>"OnSubmitForm('" .$linkSlbCategory ."')"));
	
	$selectLanguages = $this->slbLanguages;
	$linkSlbLanguages = $this->baseUrl($this->currentController . '/filter/type/lang');
	$selectLanguages = $this->formSelect('lang_code',$ssFilter['lang_code'],array('onchange'=>"OnSubmitForm('" .$linkSlbLanguages ."')"),$selectLanguages);
	
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSerach = $this->formButton('search-now','Tìm',array('onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSerach = $this->formButton('clear-keywords','Xóa',array('onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$strSearch = $keywords . ' ' . $btnSerach . ' ' . $btnResetSerach;

	$strSearchRight = $selectCategory;
?>
<form name="appForm" method="post" action="">
	<?php echo $this->render('admin-link/toolbar/index.php');?>
 	<div class="clr"></div>
	<?php echo $this->render('admin-link/sublink/index.php');?>	

	<!-- BEGIN: CONTENT -->
	<div id="element-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m">
			<!-- BEGIN: ELEMENT BOX -->
			<div id="filters">
				<div style="float: left;">
				<?php echo $strSearch;?>
				</div>
				<div style="float: right;">
				<?php echo $strSearchRight;?>
				</div>
				<div class="clr"></div>
			</div>

			<!-- Area 4: In du lieu lay tu database -->
			<table class="adminlist">
				<thead>
					<tr>
						<th width="20">#</th>
						<th width="20">
							<input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()">
						</th>
						<th width="110">
							Hình ảnh
						</th>
						<th>
							<?php echo $lblName;?>
						</th>
						<th width="60">
							<?php echo $lblStatus;?>
						</th>
						<th width="60">
							<?php echo $lblOrder;?>
						</th>
						<th width="200">
							<?php echo $lblCategory;?>
						</th>
						<th width="70">Control</th>
						<th width="34">
							<?php echo $lblID;?>
						</th>
					</tr>
				</thead>
				<?php
					foreach ($this->Items as $key => $val){
						$id 			= $val['id'];
						$name 			= $val['name'];
						$category_name 	= $val['category_name'];
						$lang_code		= $val['lang_code'];
						
						//$imgName 		= explode('/editor-upload/files/', $this->Item['picture']);
						$picture		= '<img src="' . $val['picture'] . '" style="width:100px;">';
						
						$status 		= $val['status'];
						if($status == 1){
							$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id . $page);
							$status = $this->cmsIconButton('Kích vào để tắt', $this->imgUrl . '/admin/tick.png', $linkStatus);
						}else{
							$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id . $page);
							$status = $this->cmsIconButton('Kích vào để bật', $this->imgUrl . '/admin/publish_x.png', $linkStatus);
						}
						
						$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style'=>'width: 30px; text-align: center;'));

						
						$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id . $page);
						$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
						
						$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
						$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
						
						$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $page);
						$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
						
						$strIconButton 	= $btnEdit . ' ' . $btnDelete;
						
						$alias = '<p class="smallsub">(Url: ' . $val['url'] . ' )</p>';
						$name 	= '<b><a href="' . $linkEdit . '">' . $name . '</a></b>' . $alias;
						
						$cid 			= $this->formCheckbox('cid[]',$val['id']);
						
						$classRow = 'row1';
						if($key % 2 == 0)
							$classRow = 'row0';
						
				?>
				<tr class="<?php echo $classRow;?>">
					<td align="center"><?php echo $key + 1;?></td>
					<td align="center"><?php echo $cid;?></td>
					<td align="center"><?php echo $picture;?></td>
					<td align="left"><?php echo $name;?></td>
					<td align="center"><?php echo $status;?></td>
					<td align="center"><?php echo $order;?></td>
					<td align="center"><?php echo $category_name;?></td>
					<td align="center"><?php echo $strIconButton;?></td>
					<td align="center"><?php echo $id;?></td>
				</tr>
				<?php
					} 
				?>
				<!-- BEGIN: PAGINATION (FOOT) -->
				<tfoot>
					<tr>
						<td colspan="9">
							<div class="container">
								<div class="pagination">
									<?php
										$currentUrl = $this->baseUrl($this->currentController . '/index');
										echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
									?>
								</div>
							</div>
						</td>
					</tr>
				</tfoot>
				<!-- END: PAGINATION (FOOT) -->
			</table>
			<!-- Area 4: In du lieu lay tu database - End -->

			<!-- END: ELEMENT BOX -->
			<div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
	<!-- END: 	CONTENT -->
</form>